package com.mate.cloud.xml;

import org.dom4j.Element;
import org.dom4j.Node;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * A test harness to test the addAttribute() methods on attributes
 * <a href="mailto:maartenc@users.sourceforge.net">Maarten Coene </a>
 *
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2024/6/2 20:30
 * @updateUser: MI
 * @updateTime: 2024/6/2 20:30
 * @updateRemark: 修改内容
 * @version: v1.0
 */
@SpringBootTest
public class AddAttributeTests extends AbstractTestCase {

    @Test
    public void testAddAttributeNormalValue() {
        String testAttributeName = "testAtt";
        String testAttributeValue = "testValue";

        Node authorNode = document.selectSingleNode("//root/author[1]");

        assertTrue(authorNode instanceof Element);

        Element authorEl = (Element) authorNode;
        authorEl.addAttribute(testAttributeName, testAttributeValue);

        assertEquals(3, authorEl.attributeCount());
        assertEquals(testAttributeValue, authorEl
                .attributeValue(testAttributeName));
    }
}
